package com.telit.firecommand.controller;

import com.telit.common.annotation.Log;
import com.telit.common.entity.DataReturn;
import com.telit.common.enums.BusinessOperatorType;
import com.telit.common.enums.BusinessType;
import com.telit.common.enums.OperatorType;
import com.telit.common.enums.ServiceName;
import com.telit.firecommand.dto.FireGrowExtendDTO;
import com.telit.firecommand.dto.FirePopDTO;
import com.telit.firecommand.service.GrowResponseService;
import com.telit.firecommand.vo.FireAlarmsPushVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Create by Chencf 2022/08/29
 */

@Api(tags = "指挥调度扩大响应相关接口")
@RestController
@RequestMapping("/growResponse")
public class GrowResponseController {

    @Autowired
    private GrowResponseService growResponseService;



//    //判断是否可以调用开始扑救接口
//    //判断是否可以点击扩大响应
//    @GetMapping(value = "/isOkExtend")
//    @ApiOperation("判断是否可以点击扩大响应   true可以 false不行")
//    public DataReturn<Boolean> isOkExtend(@RequestParam(value = "districtCode") String districtCode,
//                                          @RequestParam(value = "fireId") String fireId) {
//        Boolean isRescue = growResponseService.isOkExtend(districtCode,fireId);
//        return DataReturn.ok(isRescue);
//    }



    @ApiOperation("01-点击扩大响应接口 ")
    @PostMapping("/growExtend")
    @Log(service = ServiceName.FIRE_ALARMS, businessType = BusinessType.BUSINESS_LOG, operatorType = OperatorType.OTHER,businessOperatorType = BusinessOperatorType.HQZJ)
    public DataReturn growExtend(@RequestBody @Validated FireGrowExtendDTO dto){
        Map result = growResponseService.growExtend(dto);
        return DataReturn.ok(result);
    }

    //查询强制弹窗
    @ApiOperation("02-查询扩大火情提示弹窗（未读火情）  1")
    @GetMapping("getExtendPop")
    public DataReturn<List<FireAlarmsPushVO>> getPop(@RequestParam(value = "districtCode", required = true) String districtCode) {
        List<FireAlarmsPushVO> pop = growResponseService.getPop(districtCode);
        return DataReturn.ok(pop);
    }

    //关闭弹窗
    @ApiOperation("03-关闭扩大火情弹窗")
    @PostMapping("downExtendPop")
    @Log(service = ServiceName.FIRE_ALARMS, businessType = BusinessType.BUSINESS_LOG, operatorType = OperatorType.OTHER,businessOperatorType = BusinessOperatorType.ZJQS)
    public DataReturn<Boolean> downPop(@RequestBody FirePopDTO firePopDTO) {
       growResponseService.downPop(firePopDTO.getFireId());
        return DataReturn.ok(true);
    }



    //判断该火情是否扩大响应，到哪一级了
    @ApiOperation("04-点击扩大响应返回扩大范围")
    @GetMapping("isExtendFireScope")
    public DataReturn isExtendFireScope(@RequestParam(value = "fireId", required = true) String fireId,
                                        @RequestParam(value = "fireDistrictCode", required = true) String fireDistrictCode) {
        Map scopeDistrictCode = growResponseService.isExtendFireScope(fireId,fireDistrictCode);
        return DataReturn.ok(scopeDistrictCode);
    }



    //判断当前处理人能不能点击火情进行处理
    @ApiOperation("04-判断当前登陆人能不能进行扩大响应操作  返回结果true 能操作  false不能操作")
    @GetMapping("isExtendFireHandle")
    public DataReturn<Boolean> isFireHandle(@RequestParam(value = "fireId", required = true) String fireId,
                                            @RequestParam(value = "userDistrictCode", required = true) String userDistrictCode) {
        Boolean fireHandle = growResponseService.isFireHandle(fireId,userDistrictCode);
        return DataReturn.ok(fireHandle);
    }
}
